package com.yy.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yy.dto.DishDto;
import com.yy.entity.Category;
import com.yy.entity.Dish;
import com.yy.entity.DishFlavor;
import com.yy.service.DishFlavorService;
import com.yy.service.DishService;
import com.yy.service.EmployeeService;
import com.yy.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * create by KongFuning on 2022/7/31
 */
@RestController
@Slf4j
@RequestMapping("/dish")
public class DishController {

    @Autowired
    private DishService dishService;

    /*
     * 分页查询
     * */
    @GetMapping("/page")
    public R pageDish(Integer page, Integer pageSize, String name){
        return dishService.pageDish(page,pageSize,name);
    }

    /*
    * 新增菜品 同时保存对应的口味数据
    * */
    @PostMapping
    public R saveWithFlavor(@RequestBody DishDto dishDto){
        return dishService.saveWithFlavor(dishDto);
    }

    /*
    * 修改菜品 回显数据
    * */
    @GetMapping("/{id}")
    public R toUpdateWithFlavor(@PathVariable String id){
        return dishService.toUpdateWithFlavor(id);
    }

    /*
    * 修改菜品 口味
    * */
    @PutMapping
    public R updateWithFlavor(@RequestBody DishDto dishDto){
        return dishService.updateWithFlavor(dishDto);
    }

    /*
    * 添加套餐 菜品列表回显
    * */
    @GetMapping("/list")
    public R getDishList(DishDto dishDto){
        return dishService.getDishList(dishDto);
    }

    /*
    * 停售  起售
    * */
    @PostMapping("/status/{status}")
    public R isSale(@PathVariable("status") Integer status,String ids){
        return dishService.isSale(status,ids);
    }

    /*
    * 删除菜品
    * */
    @DeleteMapping
    public R deleteDish(String ids){
        return dishService.deleteDish(ids);
    }


}
